Public Class UcnDiagramCanvasAdvanced
    'represents UcnDiagramCanvasBase, panels and all components needed to work with diagram

#Region "Attributes"
#Region "Private attributes"
    Private MbReadyForUse As Boolean = False 'indicates proper initialization of usercontrol
    Private MoTabControl As UcnTabControl 'UcnTabControl which are tabs in
    Private MoTabPage As ClsUcnTabPage 'ClsTabPage which is UcnDiagramCanvasAdvanced in
    Private MoMainTabPage As ClsUcnTabPage 'Main ClsTabPage representing main tab which is this module from
#End Region
#End Region
#Region "Constructors & Init"
    Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.


        '**********************************************************************
        InitControl()
        '**********************************************************************
    End Sub
    'setting usercontrol settings after it is created
    Private Function InitControl() As GeActionResult
        SetReadyForUse(False) 'disabling usercontrol
        Try
            ucnDiagramCanvasBaseUC.xtrRibbonControl.Visible = False
            ucnDiagramCanvasBaseUC.Dock = DockStyle.Fill
            ucnActions.Dock = DockStyle.Fill
            ucnPropertiesOfItemUC.Dock = DockStyle.Fill
            ucnPropertiesOfItemUC.tlTreeList.OptionsView.ShowColumns = False
            ucnPropertiesOfItemUC.tlTreeList.OptionsSelection.EnableAppearanceFocusedCell = False
            ucnPropertiesOfItemUC.tlTreeList.OptionsSelection.EnableAppearanceFocusedRow = False
            ucnPropertiesOfTableRowsUC.Dock = DockStyle.Fill
            ucnRTFeditorUC.Dock = DockStyle.Fill

            SetReadyForUse(True) 'enabling usercontrol
            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
#End Region
#Region "Properties"
#Region "Public properties"
    Public ReadOnly Property ReadyForUse() As Boolean
        Get
            Return MbReadyForUse
        End Get
    End Property
#End Region
#End Region
#Region "Subs"
    'sets MbReadyForUse attribute and sets Enable property of usercontrol
    Private Sub SetReadyForUse(ByVal IbValue As Boolean)
        MbReadyForUse = IbValue
        Me.Enabled = IbValue 'enabling usercontrol
    End Sub
#End Region
#Region "Functions"

#End Region

    '#######################################
    'execute function
    Public Function Execute(ByRef OoAction As ClsAction) As GeActionResult
        Try
            Dim LeResult As GeActionResult = GeActionResult.kkOk
            '---------------------------------------------
            'ACTION BEFORE ACTION
            '---------------------------------------------
            '---------------------------------------------
            'ACTION
            '---------------------------------------------
            Select Case OoAction.Action
                Case GeAction.kkInitTab
                    'initialization of usercontrol for the first usage
                    'initialization of usercontrol for the first usage
                    MoTabControl = OoAction.GetData("TABCONTROL")
                    MoTabPage = OoAction.GetData("TABPAGE")
                    MoMainTabPage = OoAction.GetData("MAINTABPAGE")

                    Select Case MoTabPage.TypeOfTab
                        Case GeTypeOfTab.kkMainTab
                            nbgRelations.Visible = False

                            Dim LoList As List(Of ClsUcnListBoxItem) = New List(Of ClsUcnListBoxItem)
                            LoList.Add(New ClsUcnListBoxItem("Modul", GeTypeOfItems.kkModule, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "MODULE"), True))
                            LoList.Add(New ClsUcnListBoxItem("Komentar", GeTypeOfItems.kkNote, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "NOTE"), True))
                            ucnActions.Init(LoList, imlPanelsActions32x32, GeTypeOfItems.kkModule)
                            nbgActions.GroupClientHeight = 72
                        Case GeTypeOfTab.kkClassDiagramTab
                            nbgRelations.Visible = True

                            'ucnActions
                            Dim LoList As List(Of ClsUcnListBoxItem) = New List(Of ClsUcnListBoxItem)
                            LoList.Add(New ClsUcnListBoxItem("Trieda", GeTypeOfItems.kkTable, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "TABLE"), True))
                            LoList.Add(New ClsUcnListBoxItem("Formular", GeTypeOfItems.kkContainer, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "UNIT"), True))
                            LoList.Add(New ClsUcnListBoxItem("Komentar", GeTypeOfItems.kkNote, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "NOTE"), True))
                            ucnActions.Init(LoList, imlPanelsActions32x32)
                            nbgActions.GroupClientHeight = 106
                            'ucnRelations
                            Dim LoList2 As List(Of ClsUcnListBoxItem) = New List(Of ClsUcnListBoxItem)
                            LoList2.Add(New ClsUcnListBoxItem("1 : 0..1", KrosLib.Data.eRelationType.OneToZeroOrOne, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "1-0,1_RELATIONSHIP"), False))
                            LoList2.Add(New ClsUcnListBoxItem("1 : 1", KrosLib.Data.eRelationType.OneToOne, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "1-1_RELATIONSHIP"), False))
                            LoList2.Add(New ClsUcnListBoxItem("1 : 1..N", KrosLib.Data.eRelationType.OneToOneOrMore, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "1-1,N_RELATIONSHIP"), False))
                            LoList2.Add(New ClsUcnListBoxItem("1 : N", KrosLib.Data.eRelationType.OneToMany, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "1-N_RELATIONSHIP"), False))
                            ucnRelations.Init(LoList2, imlPanelsActions32x32, KrosLib.Data.eRelationType.OneToMany)
                            nbgRelations.GroupClientHeight = 140
                        Case GeTypeOfTab.kkUseCaseTab
                            nbgRelations.Visible = True

                            'ucnActions
                            Dim LoList As List(Of ClsUcnListBoxItem) = New List(Of ClsUcnListBoxItem)
                            LoList.Add(New ClsUcnListBoxItem("Akter", GeTypeOfItems.kkActor, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "ACTOR"), True))
                            LoList.Add(New ClsUcnListBoxItem("Aktivita", GeTypeOfItems.kkActivity, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "ACTIVITY"), True))
                            LoList.Add(New ClsUcnListBoxItem("Hranica systemu", GeTypeOfItems.kkSystemBoundary, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "SYSTEM"), True))
                            LoList.Add(New ClsUcnListBoxItem("Komentar", GeTypeOfItems.kkNote, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "Note"), True))
                            ucnActions.Init(LoList, imlPanelsActions32x32)
                            nbgActions.GroupClientHeight = 140
                            'ucnRelations
                            Dim LoList2 As List(Of ClsUcnListBoxItem) = New List(Of ClsUcnListBoxItem)
                            LoList2.Add(New ClsUcnListBoxItem("Asociacia", GeTypeOfRelationship.kkUseCaseDiagramAssociation, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "ASSOTIATION_RELATIONSHIP"), False))
                            LoList2.Add(New ClsUcnListBoxItem("Generalizacia", GeTypeOfRelationship.kkUseCaseDiagramGeneralize, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "GENERALIZATION_RELATIONSHIP"), False))
                            LoList2.Add(New ClsUcnListBoxItem("Include", GeTypeOfRelationship.kkUseCaseDiagramInclude, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "INCLUDE_RELATIONSHIP"), False))
                            LoList2.Add(New ClsUcnListBoxItem("Extended", GeTypeOfRelationship.kkUseCaseDiagramExtend, GetImageIndexFromNameInImageCollection(imlPanelsActions32x32, "EXTEND_RELATIONSHIP"), False))
                            'LoList2.Add(New ClsUcnListBoxItem("Realizacia", GeTypeOfRelationship.kkUseCaseDiagramRealize, -1, False))
                            ucnRelations.Init(LoList2, imlPanelsActions32x32, GeTypeOfRelationship.kkUseCaseDiagramAssociation)
                            nbgRelations.GroupClientHeight = 140
                    End Select

                    'assigning diagramview to overview control
                    fcOverview.DiagramView = ucnDiagramCanvasBaseUC.fcDiagramView

                    'setting captions of panels
                    dpActions.Text = "Komponenty"
                    nbgActions.Caption = "Komponenty"
                    nbgRelations.Caption = "Vztahy"
                    dpNotes.Text = "Poznamky"
                    dpProperties.Text = "Vlastnosti"
                    nbgPropertiesOfItem.Caption = "Vlastnosti"
                    nbgPropertiesOfTableRows.Caption = "Vlastnosti poloziek"
                    dpJoinedModulesInfo.Text = "Napojene polozky"
                    dpOverView.Text = "Nahlad"
                    dpItemChanges.Text = "Zmeny objektu"
                    dpVersionsChanges.Text = "Zmeny verzii"
                    nbgOverView.Caption = "Nahlad"

                    'assigning pointers of docking panels to ucnDiagramCanvasBase
                    Dim LoDockPanelsCollection As Collection = New Collection
                    LoDockPanelsCollection.Add(dpActions, "DPACTIONS")
                    LoDockPanelsCollection.Add(dpNotes, "DPNOTES")
                    LoDockPanelsCollection.Add(dpOverView, "DPOVERVIEW")
                    LoDockPanelsCollection.Add(dpProperties, "DPPROPERTIES")
                    LoDockPanelsCollection.Add(dpItemChanges, "DPITEMCHANGES")
                    LoDockPanelsCollection.Add(dpVersionsChanges, "DPVERSIONSCHANGES")
                    LoDockPanelsCollection.Add(dpJoinedModulesInfo, "DPJOINEDMODULES")
                    OoAction.SetData(LoDockPanelsCollection, "DOCKPANELSCOLLECTION")

                    'assigning pointers of usercontrols to ucnDiagramCanvasBase
                    OoAction.SetData(ucnPropertiesOfItemUC, "ucnPropertiesOfItemUC")
                    OoAction.SetData(ucnPropertiesOfTableRowsUC, "ucnPropertiesOfTableRowsUC")
                    OoAction.SetData(ucnRTFeditorUC, "ucnRTFeditorUC")
                    OoAction.SetData(ucnRelations, "ucnRelations")
                    OoAction.SetData(ucnJoinedModulesInfo, "ucnJoinedModulesInfoUC")
                    OoAction.SetData(meItemChanges, "meItemChanges")
                    OoAction.SetData(ucnVersionsChangesUC, "ucnVersionsChangesUC")
                    OoAction.SetData(xtrDockManager, "DOCKMANAGER")

                    LeResult = ucnDiagramCanvasBaseUC.Execute(OoAction)
                    '' ''Case GeAction.kkaModNewVersion
                    '' ''    'creating new aMod version
                    '' ''    LeResult = ucnDiagramCanvasBaseUC.Execute(OoAction)
                Case GeAction.kkCloseTab
                    'closing tab
                    LeResult = ucnDiagramCanvasBaseUC.Execute(OoAction)
                Case GeAction.kkaModSolutionNewSolution
                    'creating new aMod solution
                    LeResult = ucnDiagramCanvasBaseUC.Execute(OoAction)
                Case GeAction.kkaModSolutionOpenFile
                    'opening aMod solution
                    LeResult = ucnDiagramCanvasBaseUC.Execute(OoAction)
                Case GeAction.kkaModOpenVersion
                    'opening version of aMod in new tab
                    LeResult = ucnDiagramCanvasBaseUC.Execute(OoAction)
                Case GeAction.kkaModTryToOpenUCDofModule
                    'opening use case diagram of module
                    LeResult = ucnDiagramCanvasBaseUC.Execute(OoAction)
                Case GeAction.kkaModOpenUCDofModule
                    'opening use case diagram of module in tab
                    LeResult = ucnDiagramCanvasBaseUC.Execute(OoAction)
            End Select
            '---------------------------------------------
            'ACTION AFTER ACTION
            '---------------------------------------------
            Select Case OoAction.Action

            End Select
            '---------------------------------------------
            Return LeResult
            '---------------------------------------------

        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    '#######################################

End Class

' '' ''applying dock panels saved position
'' ''Private Function ApplyDockPanelsSavedPosition() As GeActionResult
'' ''    Try
'' ''        'reading settings from DS
'' ''        Dim LsString As String = MoUserSettingsFile.GetDockPanelsPosition()
'' ''        'if something was loaded = if dock panels position was saved
'' ''        If LsString <> "" Then
'' ''            'create stream
'' ''            Dim LoStream As System.IO.Stream = New System.IO.MemoryStream()
'' ''            'create streamwriter
'' ''            Dim LoStreamWriter As IO.StreamWriter = New IO.StreamWriter(LoStream)
'' ''            'write string to stream
'' ''            LoStreamWriter.Write(LsString)
'' ''            'flush = Clears all buffers for the current writer and causes any buffered data to be written to the underlying stream
'' ''            LoStreamWriter.Flush()
'' ''            'set the stream position to the beginning
'' ''            LoStream.Seek(0, System.IO.SeekOrigin.Begin)

'' ''            'restoring settings from stream
'' ''            xtrBarManager.RestoreLayoutFromStream(LoStream)
'' ''            Return GeActionResult.kkOk
'' ''        Else
'' ''            Throw New Exception
'' ''        End If

'' ''    Catch ex As Exception
'' ''        Debug.Print("CHYBA!!! - ApplyDockPanelsSavedPosition - loading dock panels position")
'' ''    End Try

'' ''    SetCheckItemPanels()
'' ''End Function
' '' ''saving dock panels position
'' ''Private Sub SaveDockPanelsSavedPosition()
'' ''    Try
'' ''        'create stream
'' ''        Dim LoStream As System.IO.Stream = New System.IO.MemoryStream()
'' ''        'saving settings to stream
'' ''        xtrBarManager.SaveLayoutToStream(LoStream)
'' ''        'set the stream position to the beginning
'' ''        LoStream.Seek(0, System.IO.SeekOrigin.Begin)
'' ''        'create streamreader
'' ''        Dim LoStreamReader As IO.StreamReader = New IO.StreamReader(LoStream)
'' ''        'read string from stream
'' ''        Dim LsString As String = LoStreamReader.ReadToEnd()

'' ''        'writing settings to DS
'' ''        MoUserSettingsFile.UpdateDockPanelsPosition(LsString)
'' ''    Catch ex As Exception
'' ''        Debug.Print("CHYBA!!! - SaveDockPanelsSavedPosition - saving dock panels position")
'' ''    End Try
'' ''End Sub